<template>
    <div class="info-container">
       <h3 class="title">{{newsinfo.top_commentsContent}}</h3>
       <p class="subtitle">
           <span>发表时间：{{newsinfo.passtime}}</span>
           <span>点击：{{newsinfo.up}}次</span>
        </p>
        <hr>
        <!-- v-html会带上标签的作用比如<p></p> 渲染完页面上是<div><p></p></div> -->
        <div class="content" v-html="newsinfo.text"></div>

        <!-- 评论区 -->
        <comment-box :id="this.id"></comment-box>
    </div>
</template>
<script>
import {Toast} from "mint-ui"

//导入子组件
import comment from '../subcomponents/comment.vue'


export default {
    data() {
        return {
            id:this.$route.params.forward,//将url地址中传递过来的id值，挂载到data上，方便以后调用
            newsinfo:{}
        }
    },
    created() {
        this.getnewsinfo()
    },
    methods: {
        getnewsinfo(){
            //get('satinGodApi?type=5&page=1'+this.id)
            this.$http.get('satinGodApi?type=5&page=1').then(result=>{
                 console.log(result.body);
                console.log(result.body.data[0]);
                
                 if(result.body.code===200){
                    this.newsinfo=result.body.data[0];
                }else{
                    Toast("获取失败")
                }
            })
        }
    },
    //定义compents组件 
      components:{
          'comment-box':comment
    },
}
</script>
<style lang="less">
    .info-container{
        padding: 0 5px;
        .title{
            font-size: 16px;
            color: red;
            text-align: center;
            margin: 15px;
        }
        .subtitle{
            color: #226aff;
            display: flex;
            justify-content: space-between;
        }
        .content{
            img{
                width: 100%;
            }
        }
    }
</style>
